import request from '@/utils/request.ts'
import { spuResponseData } from './type.ts'
export const reqSpuData = (
  page: number,
  limit: number,
  category3Id: number | string,
) =>
  request.get<any, spuResponseData>(
    `/admin/product/${page}/${limit}?category3Id=${category3Id}`,
  )
// 获取全部品牌数据
export const reqAllTradeMark = () =>
  request.get<any, any>('/admin/product/baseTrademark/getTrademarkList')
//获取图片地址
export const reqSpuImageList = (spuId: number | string) =>
  request.get<any, any>(`/admin/product/spuImageList/${spuId}`)
//销售属性
export const reqSpuSaleAttrList = (spuId: number | string) =>
  request.get<any, any>(`/admin/product/spuSaleAttrList/${spuId}`)
//全部的销售属性
export const reqAllSaleAttr = () =>
  request.get<any, any>(`/admin/product/baseSaleAttrList`)
//添加或修改spu
export const reqAddOrUpdate = (data: any) => {
  if (data.id) {
    return request.post<any, any>('/admin/product/updateSpuInfo', data)
  } else {
    return request.post<any, any>('/admin/product/saveSpuInfo', data)
  }
}
//删除
export const deleteSpu = (spuId: number | string) =>
  request.delete(`/admin/product/deleteSpu/${spuId}`)
// 保存
export const saveSku = (data: any) =>
  request.post('/admin/product/saveSkuInfo', data)
// 查看
export const reqLookSku = (spuId: number | string) =>
  request.get(`/admin/product/findBySpuId/${spuId}`)
